package main.java.com.huizluo.stagetwo.phone;

public class PhoneCard{
    private String username;//用户名
    private String password;//密码
    private CardType type;//卡类型
    private String num;//卡号码
    private double balance;//余额
    private double callTime;//通话时间
    private int netFlow;//上网流量

    private CostTotal costTotal;//消费统计
    private CallCombo call;//开通到通话套餐
    private NetCombo net;//开通到流量套餐


    public CostTotal getCostTotal() {
        return costTotal;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public CardType getType() {
        return type;
    }

    public String getNum() {
        return num;
    }

    public double getBalance() {
        return balance;
    }

    public PhoneCard(String username,String password,String num,CardType type){
        this.username = username;
        this.password = password;
        this.num = num;
        this.type = type;
        this.costTotal = new CostTotal();
    }

    //开通通话套餐
    public void selectCallCombo(CallCombo call){
        this.call = call;
        this.balance = this.balance - call.costPerMonth;
        this.costTotal.costAdd(call.costPerMonth);
    }
    //开通流量套餐
    public void selectNetCombo(NetCombo netCombo){
        this.net = netCombo;
        this.balance = this.balance - netCombo.costPerMonth;
        this.costTotal.costAdd(netCombo.costPerMonth);
    }

    //充值
    public void change(Double money){
        this.balance += money;
    }

    //显示详情信息
    public void ShowInfo() {
        System.out.printf("卡号：%s 用户名：%s 余额：%s 通话时间：%f分钟 上网流量：%dB\n", this.num, this.username, this.balance,this.callTime,this.netFlow);
    }

    //计算通话时间
    public void calculateCallTime(Integer time){
        double t = time;
        this.callTime = this.callTime + (t/60);
        this.costTotal.callTimeAdd(time);
    }
    //计算流量使用
    public void calculateFlow(Integer flow){
        this.netFlow = this.netFlow + flow;
        this.costTotal.NetFlowAdd(flow);
    }

    //计算余额
    public void calculateBalance(Double cost){
        this.balance = this.balance - cost;
    }
}
